<?php
/**
 *
 *
 * @author raphael seebacher <raphasee@ee.ethz.ch>
 * @version 0.01
 */
class config extends controller {
    protected static $config = NULL;

    public static function init() {
        $config_file = $_SERVER['DOCUMENT_ROOT'].'../config/config.ini';

        if (is_file($config_file)) {
            self::$config = parse_ini_file($config_file, true);
        }
        else {
            self::$config = Array();
        }
    }

    public static function get($key=NULL, $subkey=NULL) {
        if (!is_array(self::$config)) {
            self::init();
        }

        if ($key == NULL) {
            return self::$config;
        }
        else if (array_key_exists($key, self::$config)) {
            if ($subkey == NULL) {
                return self::$config[$key];
            }
            else if (array_key_exists($subkey, self::$config[$key])) {
                return self::$config[$key][$subkey];
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }
}
?>